<template>
	<view class="container">
		<view class="store-info flex-y-center">
			<image :src="storeInfo.firmImgs.split(',')[0] | formatFile" mode="" class="store-avatar"></image>
			<view class="right-info">
				<view class="store-name">{{storeInfo.firmName}}</view>
				<view class="gray-text">{{storeInfo.mainBusiness}}</view>
				<view class="gray-text">{{storeInfo.province}}{{storeInfo.city}}{{storeInfo.area}}</view>
			</view>
		</view>

		<view class="title">店铺商品</view>
		<view class="product-list" v-if="storeInfo.products.length">
			<ProductItem v-for="(item, index) in storeInfo.products" :key="item.id" :productInfo="item"></ProductItem>
		</view>
		<u-empty textSize="28" iconSize="180" marginTop="80" text="暂无商品" v-else></u-empty>
	</view>
</template>

<script>
	import {
		getStoreDetail
	} from '@/api/store.js'
	import ProductItem from '@/components/ProductItem/ProductItem.vue'
	export default {
		components: {
			ProductItem
		},
		data() {
			return {
				id:'',
				storeInfo: {
					firmImgs: '',
					products:[]
				}
			}
		},
		onLoad(option){
			this.id = option.id
			this.getStoreDetail()
		},
		methods: {
			getStoreDetail() {
				getStoreDetail({id: this.id}).then(res => {
					this.storeInfo = res.result
				})
			}
		}
	}
</script>

<style lang="scss">
	.store-info {
		background: #FFFFFF;
		border-radius: 19rpx;
		padding: 30rpx;
		margin-bottom: 30rpx;
		margin: 30rpx;

		.store-avatar {
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			flex-shrink: 0;
		}

		.right-info {
			flex: 1;
			margin-left: 30rpx;

			.store-name {
				font-size: 33rpx;
				color: #333333;
				font-weight: 500;
			}

			.gray-text {
				font-size: 27rpx;
				color: #808080;
				padding-top: 10rpx;
			}
		}
	}

	.title {
		margin: 30rpx;
		font-weight: bold;
		font-size: 33rpx;
		color: #333333;
	}

	.product-list {
		margin: 30rpx;
	}
</style>